﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace canyinguanlixitong
{
    public partial class frmaddczy : Form
    {
        public frmaddczy()
        {
            InitializeComponent();
        }

        private void frmaddczy_Load(object sender, EventArgs e)
        {

        }
        string strconn = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";
        public void add() {
            SqlConnection conn = new SqlConnection(strconn);
            conn.Open();
            int id =Convert.ToInt32(this.textBox1.Text);
            string name = this.textBox2.Text;
            string pwd = this.textBox3.Text;
            string sql = "insert into [User](userID,id,pwd) values('"+id+"','"+name+"','"+pwd+"')";
            SqlCommand cmd = new SqlCommand(sql,conn);
            int i=cmd.ExecuteNonQuery();
            if (i>0)
            {
                MessageBox.Show("新增成功","提示",MessageBoxButtons.OKCancel);
                
            }
            else
            {
                MessageBox.Show("新增失败");
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            add();
        }
    }
}
